package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SystemDictionary;
import cn.wolfcode.crm.mapper.SystemDictionaryMapper;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//使用IOC的注解告诉SPring来帮我们管理当前对象
@Service
public class SystemDictionaryServiceImpl implements ISystemDictionaryService {
    @Autowired//自动注入
    private SystemDictionaryMapper mapper;
    @Override
    public void save(SystemDictionary systemDictionary) {
        mapper.save(systemDictionary);
    }

    @Override
    public void delete(Long id) {
        mapper.delete(id);
    }

    @Override
    public void update(SystemDictionary systemDictionary) {
        mapper.update(systemDictionary);
    }

    @Override
    public SystemDictionary get(Long id) {
        return mapper.get(id);
    }

    @Override
    public List<SystemDictionary> listAll() {
        return mapper.listAll();
    }

    @Override
    public PageResult query(QueryObject qo) {
        //封装用户需要的数据
        int count = mapper.selectForCount(qo);
        List<SystemDictionary> list = mapper.selectForList(qo);

        //将用户需要的所有的数据封装起来
        return new PageResult(list,count,qo.getCurrentPage(),qo.getPageSize());
    }


}
